package com.wei.outputformat;

import java.io.IOException;

import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.RecordWriter;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class LogEnhancerOutputFormat extends FileOutputFormat<Text, NullWritable>{

	@Override
	public RecordWriter<Text, NullWritable> getRecordWriter(
			TaskAttemptContext context) throws IOException, InterruptedException {
		FileSystem fileSystem=FileSystem.get(context.getConfiguration());
		Path enhancePath = new Path("hdfs://node2:9000/enhancelog/enhanced.log");
		Path toCrawlPath = new Path("hdfs://node3:9000/enhancelog/toCrawl.log");
		FSDataOutputStream enhanceOutputStream = fileSystem.create(enhancePath);
		FSDataOutputStream toCrawlputStream = fileSystem.create(toCrawlPath);
		MyRecordWriter recordWriter=new MyRecordWriter(enhanceOutputStream, toCrawlputStream);
		return recordWriter;
	}

}
